class Solution:
    def sortedSquares(self, nums: List[int]) -> List[int]:
        l = 0
        n = len(nums)
        lst = [0]*n
        r = n -1
        pos = n-1
        while l <= r :
            if nums[l] * nums[l] > nums[r]* nums[r]:
                lst[pos] =  nums[l]* nums[l]
                l+=1
            else:
                lst[pos] =  nums[r]* nums[r]
                r-=1
            pos-=1
        return lst